package com.alipay.sofa.boot.examples.demo.rpc.controller;

import com.alipay.sofa.boot.examples.demo.rpc.bean.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by TS-Ysh on 2018-05-04.
 */
@RestController
public class Test1Controller {

    @Resource(name = "personReferenceBolt")
    private PersonService personBolt;

    @Resource(name = "personReferenceRest")
    private PersonService personRest;

//    PersonService personBolt = (PersonService) applicationContext
//            .getBean("personReferenceBolt");
//    PersonService personRest = (PersonService) applicationContext
//            .getBean("personReferenceRest");

    @GetMapping("test1a")
    public String test1a() throws InterruptedException {
        for(int i=0;i<100;i++){
            Thread.sleep(200);
            System.out.println(personBolt.sayName("bolt" + i));
            System.out.println(personRest.sayName("rest" + i));
        }

        return "success";
    }
}
